home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9695 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.9 KB

  1. Path: newshost.netinfo.com.au!usenet
  2. From: Alan Brain <aebrain@dynamite.com.au>
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
  4. Subject: Re: C/C++ knocks the crap out of Ada
  5. Date: 2 Mar 1996 23:09:41 GMT
  6. Organization: Netinfo Pty Ltd - Canberra Australia
  7. Message-ID: <4hakfl$ogd@fred.netinfo.com.au>
  8. References: <JSA.96Feb16135027@organon.com> <1996Feb22.005518.13396@leeweyr.sccsi.com> <4gvrffINNlqo@anvil.ugrad.cs.ubc.ca> <SPENCER.96Feb29102241@zorgon.ERA.COM> <4h5bptINN9oi@anvil.ugrad.cs.ubc.ca>
  9. NNTP-Posting-Host: dialup2.dynamite.com.au
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
  14.  
  15. c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
  16.  
  17.  
  18. >You are confusing the language specification with the implementation. The C
  19. >specification does not call for the ability randomly access memory. The only
  20. >way to legally manufacture pointers is by taking the addresses of named
  21. >objects, using the standard defined function malloc() or through pointer
  22. >arithmetic (adding an integral displacement to an existing pointer---an
  23. >operation which yields undefined results if you try to create a pointer outside
  24. >of an object). You aren't even legally allowed to subtract two pointers that
  25. >don't reference the same object, even if they have compatible types.
  26.  
  27. Agree. But if a Cosmic Ray comes and Zapps a bit, this could happen. Or if a 
  28. memory chip wasn't quite up to par. Ada 83 will catch it at the next 
  29. type-check, raise an exception, and trigger whatever error-correction has been 
  30. designed into the program. Yes, if that's insufficient, you have problems.
  31.  
  32. But in C you carry on, Fat, Dumb and Happy, over-writing God knows what. Bit 
  33. of a blow if the program's in control of a Nuclear powerplant. Or a 
  34. flight-control system. Could even be nasty if it's the Stock exchange, can 
  35. anyone say 'Instant Economic Depression'.
  36.  
  37. >If C is ``unsafe'', C++ is lethal.
  38.  
  39. Agree.
  40.  
  41. >Whether C is more or less unsafe than Ada is truly debatable.  A
  42. >standard-conforming, _quality_ implementation of either language coupled with
  43. >adherent programs subject to rigorous quality control is suitable for
  44. >safety-critical software.
  45.  
  46. See above example. EVEN IF THE CODE IS BUG FREE ( a big ask IMHO ) there will 
  47. occur problems - hardware problems - which the C language cannot detect by its 
  48. very nature, and so cannot correct. Ada 83 gives a greater - though not 
  49. absolute - ability to the programmer so the program can cope with bugs, hard 
  50. failures and soft failures, and STILL work. Sorry, but being able to say to 
  51. the relatives 'No fair, it was a cosmic-ray induced glitch, the software was 
  52. bug free' cuts no mustard if the plane crashed as the result of an 
  53. out-of-index parameter.
  54.  
  55. To give a concrete example, I - along with some very inexperienced programmers 
  56. - recently wrote a Threat Evaluation and Weapon Assignment segment. One which 
  57. would kill people if it didn't work exactly right, either by shooting at 
  58. friendlies, or allowing a missile through to hit the ship.
  59. When first ported to the target hardware, it ran. Badly. The error log was 
  60. going berserk, there were large quantities of minor errors, and 3 major ones. 
  61. But it STILL did the job - slowly. Over 95% of its time was spent doing 
  62. error-correction and reporting, literally. When the last of the bugs we found 
  63. was detected, we'd speeded it up by a factor of over 20. Due to the hardware 
  64. we were interfacing with being not quite up to spec (proven) - and probably 
  65. other bugs we hadn't found -, the error log was still getting 20-30 errors/sec 
  66. (as opposed to 650 ). But it still worked, despite errors that would certainly 
  67. have caused Kernel Panic Core Dumped every few minutes if 'twere in C.
  68.  
  69. That's the key to success in my experience. Ada 83 code cannot be Bug-Free, 
  70. but it can be Bug-Resistant. C - except in certain ways, and with an 
  71. increase of up to 10 times the coding effort - can't.
  72.  
  73.